package com.hwy.chart.coordinate

import android.graphics.Canvas
import android.graphics.RectF
import com.hwy.chart.coordinate.axis.ChartXAxis
import com.hwy.chart.coordinate.axis.ChartYAxis

/**
 * =======================================
 * 作者: hewenyu
 * 日期: 2022/5/10 15:25
 * 说明: 坐标系抽象类
 * @param T x轴坐标数据类型
 * @param E y轴坐标数据类型
 * =======================================
 */
abstract class BaseCoordinate<T, E> where E : Number, E : Comparable<E> {

    /**
     * 坐标系x轴
     */
    var xAxis: ChartXAxis<T> = ChartXAxis()

    /**
     * 坐标系y轴
     */
    var yAxis: ChartYAxis<E> = ChartYAxis()

    /**
     * 坐标系网格线
     */
    var gridLine: CoordinateGridLine = CoordinateGridLine()

    /**
     * 绘制坐标系
     */
    abstract fun draw(canvas: Canvas, bounds: RectF)

    /**
     * 绘制网格线
     */
    protected open fun drawGridLine(canvas: Canvas, bounds: RectF) {
        gridLine.draw(canvas, bounds)
    }

    /**
     * 绘制坐标轴
     */
    protected open fun drawAxis(canvas: Canvas, bounds: RectF) {
        xAxis.draw(canvas, bounds)
        yAxis.draw(canvas, bounds)
    }
}